package com.ce.pms.log4ce;

import java.util.Map;

import org.aspectj.lang.JoinPoint;

import com.ce.component.log4ce.aop.constructor.support.AbstractOriginalObjectHolder;
import com.ce.component.log4ce.aop.constructor.support.OriginalObjectHolder;
import com.ce.component.log4ce.aop.parser.BizLogParser;
import com.ce.pms.customer.vo.CustomerVO;

public class CustomerDeleteHolder extends AbstractOriginalObjectHolder implements OriginalObjectHolder {

	private Log4ceHelper log4ceHelper = Log4ceHelper.getInstance();
	@Override
	protected Map<String, Object> getOriginalObjects(JoinPoint joinPoint, BizLogParser logParser) {

		Map<String,Object> map = logParser.getLogArguments(joinPoint);

		//获取参与人ID，此map中的key值在Log4ceLogCfg.xml中的LogArguments节点中定义。
		Long participantId = (Long)map.get("participantId");
		String participantTypeCode = (String)map.get("participantTypeCode");
		String patternStr = joinPoint.toShortString();
		String customerTypeCode = null;
		//在方法执行前就拿到房号,执行完时再拿关系以不存在
		if(patternStr.indexOf("Owner")!= -1){
			customerTypeCode  = CustomerVO.OWNER_CODE;
		}else if(patternStr.indexOf("Lessee")!= -1){
			customerTypeCode  = CustomerVO.LESSEE_CODE;
		}
		String houseNumber = log4ceHelper.genHouseNumbers(log4ceHelper.getSourceHouses(participantId,customerTypeCode));
		map.put("houseNumber", houseNumber);
		map.put("customerInfo", log4ceHelper.getCustomerById(participantId,participantTypeCode));
		return map;
	}

}
